package com.bonc.ioc.demo.contorller;

import com.bonc.ioc.common.util.AppReply;
import com.bonc.ioc.demo.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author LENOVO
 */
@RestController
@Slf4j
public class FileController {
    @Autowired
    FileService fileService;

    @PostMapping("/uploadFile")
    @ResponseBody
    public AppReply upload(@RequestParam("file")MultipartFile file,
                           @RequestParam("project")String project){
        fileService.upload(file,project);
        return AppReply.success();
    }

    @GetMapping(value = "/download")
    @ResponseBody
    public AppReply download(int id){
        return AppReply.success(fileService.download(id));
    }



}
